//引入sequelize模块
let Sequelize = require('sequelize')
let CONFIG = require('./config.js')

//实例化数据库对象
let sequelize = new Sequelize(
  //配置数据库名称
  CONFIG.MYSQL.database,
  //数据库登录名称
  CONFIG.MYSQL.username,
  //数库库登录密码
  CONFIG.MYSQL.password,
  //数据库参数
  {
    //数据库连接地址
    host: CONFIG.MYSQL.host,
    //连接的数据库类型
    dialect: 'mysql',
    //是否打印日志
    logging: CONFIG.DEBUG ? console.log : false,
    //配置数据库连接池
    pool: {
      max: 10,
      min: 0,
      idle: 10000,
    },
    //配置时区
    timezone: '+08:00',
  }
)
module.exports = sequelize
